package cn.itsource.itsource.controller;

import cn.itsource.itsource.domain.SearchMasterMessage;
import cn.itsource.itsource.query.SearchMasterMessageQuery;
import cn.itsource.itsource.service.ISearchMasterMessageService;
import cn.itsource.itsource.util.AjaxResult;
import cn.itsource.itsource.util.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/searchmaster")
public class SearchMasterMessageController {
    @Autowired
    private ISearchMasterMessageService searchMasterMessageService;


    @PostMapping("/publish")
    public AjaxResult publish(@RequestBody SearchMasterMessage searchMasterMessage, HttpServletRequest request){
            String token=request.getHeader("token");
        return searchMasterMessageService.publish(searchMasterMessage,token);
    }

    /**
     * 分页查询发布的寻主列表
     *
     * @param query
     * @return
     */
    @PostMapping("/findpage")
    public PageList<SearchMasterMessage> findPage(@RequestBody SearchMasterMessageQuery query) {
        return searchMasterMessageService.findPage(query);
    }

}
